package com.more.offer.designpatterns.unit1;

import java.util.HashMap;
import java.util.Map;

/**
 * @author pinoc
 * @date 2021/7/25
 * @description 工厂类，缓存（存储）初始化棋子
 */
public class ChessPieceUnitFactory {

	private static final Map<Integer, ChessPieceUnit> pieces = new HashMap<>(16);

	static{
		pieces.put(1, new ChessPieceUnit(1,"车", ChessPieceUnit.Color.BLACK));
		pieces.put(1, new ChessPieceUnit(2,"马", ChessPieceUnit.Color.RED));
		//...
	}

	public static ChessPieceUnit getChessPieceUnit(int id) {
		return pieces.get(id);
	}
}
